package com.morgan.storageperlib.saf.handler

import android.content.Intent
import android.net.Uri
import androidx.activity.result.ActivityResult
import androidx.activity.result.contract.ActivityResultContract
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import com.morgan.storageperlib.utils.Utils

/**
 *description：通过SAF打开，回调Uri
 *<br>author：caowugao
 *<br>time：2021/3/5 0005 18:10
 */
open class OpenFileHandler (act : AppCompatActivity, contract : ActivityResultContract<Intent, ActivityResult> = ActivityResultContracts.StartActivityForResult(), callback : (Uri) -> Unit) : OpenOriginalFileHandler(act, contract, { result ->
    Utils.convertResult2Uri(result)?.let { uri ->
        callback.invoke(uri)
    }
}) {

    open fun openFile(imeiType : String = "*/*") {
        openOriginalFile(imeiType)
    }
}